// ------------ 绘制函数 ------------------
import {
    renderAreaNode
} from "./renderAreaNode"

var subAdcode;

export function addDeClick(districtExplorer, adcode, map, that) {
    districtExplorer.on("featureClick outsideClick", function (e, feature) {
        // 点击了行政区外侧
        if (feature === null) {
            districtExplorer.loadAreaNode(adcode, function (error, areaNode) {
                if (error) {
                    console.error(error);
                    return;
                }
                renderAreaNode(districtExplorer, areaNode, map);
            });
            that.$emit("mapBeClick", undefined);
            return 0
        }
        subAdcode = feature.properties.adcode;
        // -------- 绘制节点 --------------
        districtExplorer.loadAreaNode(adcode, function (error, areaNode) {
            if (error) {
                console.error(error);
                return;
            }
            renderAreaNode(districtExplorer, areaNode, map, subAdcode);
        });
        that.$emit("mapBeClick", subAdcode);
    });
}